﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Numerics;

namespace Gebra.Test
{
    [TestClass]
    public class AddTest
    {
        [TestMethod]
        public void ConstructWithNumbers()
        {
            var add = new Add(new Number(23), new Number(42));

            var result = add.Evaluate() as Number;

            Assert.IsNotNull(result);
            Assert.AreEqual(65, (double)result);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructWithNullLeft()
        {
            new Add(a_left: null, a_right: (Number)42);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructWithNullRight()
        {
            new Add((Number)23, a_right: null);
        }

        [TestMethod]
        public void EvaluateThreeNumberAddition()
        {
            // 23 + 36 + 42 = 101
            var add = new Number(23).Add(36).Add(42);

            var result = add.Evaluate() as Number;

            Assert.AreEqual(101, (double)result);
        }
    }
}
